1 哪些方法可以用
在翻看了众多页面之后,可以列出一些可以尝试的点:
1.1 直接打开URL window.open
1.2 HTML5 A 标签 的download属性
可以如下实现
<a href="/url/to/file/path" download="downloadName">点击下载</a>
1.3 使用封装的JavaScript库
2 参考资料
- Save/download data generated in JavaScript
- JavaScript Local I/O tests
- Force Download an Image Using Javascript
- How to trigger a file download when clicking an html button or javascript
- Using HTML5/Javascript to generate and save a file
- 在浏览器端用JS创建和下载文件
- JavaScript多文件下载
- JavaScript多文件下载
- Starting file download with Javascript
- 什么是data URI scheme及如何使用data URI scheme
- Data URI和MHTML完整解决所有浏览器
- DataURL在Web浏览器中的兼容性总结
- Download data url file
- JS魔法堂:Data URI Scheme介绍
- How to write a file / give it to the user
- HTML5 Cross Browser Polyfills
- How to force save as dialog box in firefox besides changing headers?
- Better approach to download file in JavaScript
- Does execCommand SaveAs work in Firefox?
- Saving generated files on the client-side
- Save to Drive Button
- 通过js保存图片到本地
2.1 HTTP Content Disposition
2.2 HTML5 A 标签
- W3C HTML5 A
- HTML: The Living Standard
- HTML5 download attribute with JavaScript
- Better approach to download file in JavaScript
- Save files on disk using JavaScript
- Downloading resources in HTML5
- 变通方法实现保存文件
2.3 下载库参考 HTML5
- Blob.js
- canvas-toBlob.js
- FileServer.js
- Downloadify
- Downloadify Example
- jquery.fileDownload
- jQuery File Download Plugin for Ajax
最后更新: 2022年03月02日 03:32
原始链接: http://rawbin-.github.io/dev-app/javascript/2015-09-04-javascript-click-download/